var request = require('request'),
	cheerio = require('cheerio'),
	baseUrl = 'http://www.bloomberg.com/profiles/companies/{0}:US',
	ticker = process.argv[2],
	url = baseUrl.replace('{0}', ticker);

req = request(url, function(err, resp, body) {
	var $ = cheerio.load(body);
	var $sectorDiv = $($('.sector').get(0));
	var $industryDiv = $($('.industry').get(0));
	var $subIndustryDiv = $($('.sub_industry').get(0));
	var $descriptionDiv = $($('.description').get(0));
	
	var sector = $sectorDiv.text().replace('Sector: ', '');
	var industry = $industryDiv.text().replace('Industry: ', '');
	var subIndustry = $subIndustryDiv.text().replace('Sub-Industry: ', '');
	var description = $descriptionDiv.text();
	
	if (sector.length == 0 || industry.length == 0 || subIndustry.length == 0 || description.length == 0)
	{
		return;
	}
	
	console.log(sector);
	console.log(industry);
	console.log(subIndustry);
	console.log(description);
});

setTimeout(function(){
	req.abort();
}, 2000);